package com.conversationboard.database;

public class PerformanceRecord implements Comparable<PerformanceRecord> {

	private String callerName;
	private long count;
	private long totalTime;
	private long minTime;
	private long maxTime;


	public PerformanceRecord() {
		this.maxTime = 0;
		this.minTime = 100000000000000000l;
	}


	public int compareTo(PerformanceRecord record) {
		return (this.callerName.compareTo(record.callerName));
	}


	public long getAverageTime() {

		if (count == 0) {
			return 0;
		} else {
			return totalTime / count;
		}
	}


	public void incrementTime(long time) {
		this.totalTime += time;

		if (time < minTime) {
			this.minTime = time;
		}

		if (time > maxTime) {
			this.maxTime = time;
		}
	}


	public void incrementCount() {
		this.count++;
	}


	public long getCount() {
		return count;
	}


	public long getTotalTime() {
		return totalTime;
	}


	public String getCallerName() {
		return callerName;
	}


	public void setCallerName(String callerName) {
		this.callerName = callerName;
	}


	public long getMinTime() {
		return minTime;
	}


	public long getMaxTime() {
		return maxTime;
	}

}
